package co.fitstart.coach.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dynamic;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;

import co.fitstart.entity.courseware.dietary.DietaryProgramTemplate;
import co.fitstart.entity.courseware.fitnessgroup.BatchCoursewareTemplate;
import co.fitstart.entity.courseware.fitnessgroup.BatchCoursewareType;
import co.fitstart.entity.courseware.fitnessgroup.CoursewareTemplate;
import co.fitstart.entity.courseware.fitnessgroup.DailyCoursewareTemplate;
import co.fitstart.entity.courseware.fitnessgroup.FitnessGroup;
import co.fitstart.entity.courseware.fitnessgroup.SpecialCoursewareTemplate;

@Dynamic("hibernate")
public interface CoursewareTemplateDao {
    
    /**
     * 
     * @param dailyCoursewareTemplate
     * @return
     */
    @Query("FROM CoursewareTemplate WHERE disabled = false AND daily = :daily ORDER BY id")
    public List<CoursewareTemplate> listCoursewareTemplate(@Variable("daily") DailyCoursewareTemplate dailyCoursewareTemplate);
    
    /**
     * 
     * @param batch
     * @return
     */
    @Query("FROM DailyCoursewareTemplate WHERE disabled = false AND batch = :batch ORDER BY sorting")
    public List<DailyCoursewareTemplate> listDailyCoursewareTemplate(@Variable("batch") BatchCoursewareTemplate batch);
    
    /**
     * 
     * @param fitnessGroup
     * @return
     */
    @Query("FROM BatchCoursewareTemplate WHERE disabled = false AND fitnessGroup = :fitnessGroup")
    public List<BatchCoursewareTemplate> listBatchCoursewareTemplate(@Variable("fitnessGroup") FitnessGroup fitnessGroup);
    
    /**
     * 
     * @return
     */
    @Query("FROM DietaryProgramTemplate WHERE disabled = false")
    public List<DietaryProgramTemplate> listDietaryProgramTemplate();
    
    /**
     * 
     * @param fitnessGroup
     * @return
     */
    @Query("FROM SpecialCoursewareTemplate WHERE disabled = false AND fitnessGroup = :fitnessGroup")
    public SpecialCoursewareTemplate loadSpecialCoursewareTemplate(@Variable("fitnessGroup") FitnessGroup fitnessGroup);
    
    /**
     * 
     * @param specialCoursewareTemplate
     * @return
     */
    @Query("FROM CoursewareTemplate WHERE disabled = false AND special = :special ORDER BY id")
    public List<CoursewareTemplate> listCoursewareTemplate(@Variable("special") SpecialCoursewareTemplate specialCoursewareTemplate);

    /**
     * 
     * @param fitnessGroup
     * @param type
     * @param sorting
     * @return
     */
    @Query("FROM BatchCoursewareTemplate WHERE disabled = false AND fitnessGroup = :fitnessGroup AND type =:type AND sorting = :sorting")
    public BatchCoursewareTemplate loadBatchCoursewareTemplate(@Variable("fitnessGroup") FitnessGroup fitnessGroup, @Variable("type") BatchCoursewareType type, @Variable("sorting") int sorting);
}
